package com.javafactroy.kunlong.bip.socket;

import com.javafactroy.kunlong.bip.IcpAppl;
import com.javafactroy.kunlong.bip.icp.message.base.iface.IMessage;

import com.javafactroy.kunlong.bip.icp.message.dxp.base.DxpMsg;
import com.javafactroy.kunlong.bip.icp.socket.client.SocketTcpClient;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit.jupiter.SpringExtension;

import java.io.IOException;

@SpringBootTest(classes = {IcpAppl.class}, webEnvironment = SpringBootTest.WebEnvironment.NONE)
@ExtendWith(SpringExtension.class)
@Slf4j
public class TestSocketClient {
    @Autowired
    SocketTcpClient socketTcpClient;

    @Test
    public void TestSendClose() throws IOException {
        socketTcpClient.send(DxpMsg.buildCloseMessage());
    }

    @Test
    public void TestSend2local() throws IOException {
       socketTcpClient.setIpPort("127.0.0.1",12022);//.getProps().setProperty("ip","192.168.4.119");
        IMessage resp =socketTcpClient.send(  DxpMsg  .buildMessage());
        log.info("TestSend2local DxpMsgResp={}",resp);

    }

    @Test
    public void TestSend2Netty() throws IOException {
       socketTcpClient.setIpPort("127.0.0.1",6666);
        IMessage message=socketTcpClient.send(  DxpMsg.buildMessage());
        log.info("TestSend2Netty DxpMsgResp={}",message);

    }
}
